/**
 * @(#)MemcachedUtil.java, 2013-2-12. Copyright 2013 RENREN, Inc. All rights
 *                         reserved. RENREN PROPRIETARY/CONFIDENTIAL. Use is
 *                         subject to license terms.
 */
package com.wennimei.util;

import java.io.IOException;
import java.net.InetSocketAddress;

import net.spy.memcached.MemcachedClient;

/**
 * @author shichen.feng@renren-inc.com
 */
public class MemcachedUtil {
    private static MemcachedClient mc = null;

    private static MemcachedUtil instance = new MemcachedUtil();

    public static MemcachedUtil getInstance() {
        return instance;
    }

    private MemcachedUtil() {
        try {
            mc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 12000));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void set(String key, int exp, Object obj) {
        mc.set(key, exp, obj);
    }

    public Object get(String key) {
        return mc.get(key);
    }

    public void remove(String key) {
        mc.delete(key);
    }
}
